import {INCREMENT,DECREMENT} from "./mutation-type.js"

const app = {
	state: {
		count: 0
	},
	getters: {
		myCount(state) {
			return `current count is ${state.count}`
		}
	},
	mutations: {
		// increment(state, n) {
		// 	// state.count++
		// 	state.count += n
		// },
		// decrement(state, n) {
		// 	// state.count--
		// 	state.count -= n
		// }
		[INCREMENT](state, n=1) {
			// state.count++
			state.count += n
		},
		[DECREMENT](state, n=1) {
			// state.count--
			state.count -= n
		}
	},
	actions: {
		async myIncrease(context) {
			context.commit('INCREMENT', 2)

			const products = [1, 2, 3, 4, 5] //await axios.get(.....)
			return products
		},
		myDecrease(context) {
			context.commit('DECREMENT', 1)
		}
	}
}

export default app
